//
//  RootViewController.m
//  110
//
//  Created by lanou on 16/4/12.
//  Copyright © 2016年 乔砥. All rights reserved.
//

#import "RootViewController.h"
#import "HomePageViewController.h"
#import "AppDelegate.h"
#import "MyTabBarViewController.h"



@interface RootViewController ()

@property(nonatomic,strong)UIImageView *qtImageView;


@property(nonatomic,strong)UIImageView *loveImageView;


@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // navigation两边button 的颜色
    [self.navigationController.navigationBar setTintColor:[UIColor blackColor]];
    // navigation字体的颜色 大写 型号
    [self.navigationController.navigationBar setTitleTextAttributes: @{NSFontAttributeName: [UIFont fontWithName:@"Arial-BoldItalicMT" size:19],
                                                                       
                                                                       
                                                                       NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, KWIDTH, KHEIGHT)];
    imageView.image = [UIImage imageNamed:@"login_register_background.png"];
    [self.view addSubview:imageView];
       UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(0,0,0, 0)];
         label1.text = @"天气阴晴不定,请预防感冒!";
   // label1.numberOfLines = 0;
       label1.font = [UIFont systemFontOfSize:10];
        label1.textColor = [UIColor whiteColor];
    
    [self.view addSubview:label1];
    
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(40, 200, KWIDTH - 80, 80)];
    label2.text = @"用药百科,爱就在身边 ~";
    label2.font = [UIFont fontWithName:@"Arial-BoldItalicMT" size:20];
    label2.textAlignment = NSTextAlignmentRight;
    label2.textColor = [UIColor whiteColor];
    CGRect frame = label2.frame;
    
    frame.origin.x = -180;
    
    label2.frame = frame;
    
    [UIView beginAnimations:@"testAnimation" context:NULL];
    
    [UIView setAnimationDuration:8.8f];
    
    [UIView setAnimationCurve:UIViewAnimationCurveLinear];
    
    [UIView setAnimationDelegate:self];
    
    [UIView setAnimationRepeatAutoreverses:NO];
    
    [UIView setAnimationRepeatCount:999999];
    
    frame = label2.frame;
    
    frame.origin.x = 350;
    
    label2.frame = frame;
    
    [UIView commitAnimations];

    
    
    
    
    
    [imageView addSubview:label2];
        
        [UIView animateWithDuration: 4 animations:^{
            
            label1.font = [UIFont fontWithName:@"AmericanTypewriter-Bold" size:22];
          label1.textAlignment = NSTextAlignmentRight;
            label1.frame =CGRectMake(30, 100, KWIDTH -60, 100);
            
          
            
//            [UIView animateWithDuration:3 animations:^{
//                
//                label2.frame = CGRectMake(40, 200, KWIDTH - 80, 80);
//                label2.font = [UIFont fontWithName:@"Arial-BoldItalicMT" size:20];
//                label2.textAlignment = NSTextAlignmentRight;
//
//                }];

        }];
    
    // 字体的大小在运动过程中 没有轨迹 所以在动画中做不出改变字体大小的效果
    
    
   
    UIView *myView = [[UIView alloc]initWithFrame:CGRectMake(KWIDTH / 2, KHEIGHT, 0, 0)];
    myView.alpha = 0.5;
    [self.view addSubview:myView];
    
    
   _button = [UIButton buttonWithType:UIButtonTypeSystem];
    _button.frame = CGRectMake(KWIDTH / 2, KHEIGHT, 0, 0);
    [_button.layer setCornerRadius:10];
    _button.layer.masksToBounds = YES;
    [_button setTitle:@"点击进入" forState:UIControlStateNormal];
    _button.titleLabel.font = [UIFont systemFontOfSize:16];
    [_button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    _button.showsTouchWhenHighlighted = YES;
    [_button setBackgroundImage:[UIImage imageNamed:@"add_new_poi_type_select_bg"] forState:UIControlStateNormal];
    [myView addSubview:_button];
    
    
    
    _qtImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0,  KHEIGHT / 3 - 190, 0, 0)];
    _qtImageView.image = [UIImage imageNamed:@"TZ"];
    [self.view addSubview:_qtImageView];
    
    
    [UIView animateWithDuration:5 animations:^{
        
         _qtImageView.frame = CGRectMake(KWIDTH / 2 - 128,40, 259, 76);
    
   
    }];
    
   
    
    _loveImageView = [[UIImageView alloc]initWithFrame:CGRectMake(KWIDTH / 2 - 100, KHEIGHT - 22, 192, 27)];
    _loveImageView.image = [UIImage imageNamed:@"love"];
    [self.view addSubview:_loveImageView];
    
    
    
    
    
    
    [UIView animateWithDuration:3 animations:^{
        
        myView.frame = CGRectMake(20, KHEIGHT - 60, KWIDTH - 40, 30);
        _button.frame = CGRectMake(3, 2, KWIDTH - 40, 30);
     
       
    }];
    [_button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    

    
    UIImageView *myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(KWIDTH / 2 - 60, KHEIGHT / 2 + 50, 120, 120)];
    myImageView.alpha = 0;
    
    myImageView.image = [UIImage imageNamed:@"icon.png"];
    [imageView addSubview:myImageView];
    
    
    [UIView animateWithDuration:5 animations:^{
        
        myImageView.alpha = 1;
    }];
    

    
    
}








-(void)buttonAction:(UIButton *)button
{
    AppDelegate *app = [UIApplication sharedApplication].delegate;
    MyTabBarViewController *tab = [[MyTabBarViewController alloc]init];
    
    [UIView animateWithDuration:1 animations:^{
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:YES];
      app.window.rootViewController = tab;

    
    }];
    
      
    

    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
